package com.ruoyi.project.tencent.controller;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.tencent.domain.TcConfig;
import com.ruoyi.project.tencent.service.ITcConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 腾讯云-图像识别配置参数Controller
 *
 * @author ruoyi
 * @date 2020-06-08
 */
@RestController
@RequestMapping("/tc/config")
public class

TcConfigController extends BaseController {
    @Autowired
    private ITcConfigService tcConfigService;

    /**
     * 查询腾讯云-图像识别配置参数列表
     */
    @PreAuthorize("@ss.hasPermi('tc:config:list')")
    @GetMapping("/list")
    public TableDataInfo list(TcConfig tcConfig) {
        startPage();
        List<TcConfig> list = tcConfigService.selectTcConfigList(tcConfig);
        return getDataTable(list);
    }

    /**
     * 导出腾讯云-图像识别配置参数列表
     */
    @PreAuthorize("@ss.hasPermi('tc:config:export')")
    @Log(title = "腾讯云-图像识别配置参数", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TcConfig tcConfig) {
        List<TcConfig> list = tcConfigService.selectTcConfigList(tcConfig);
        ExcelUtil<TcConfig> util = new ExcelUtil<TcConfig>(TcConfig.class);
        return util.exportExcel(list, "config");
    }

    /**
     * 获取腾讯云-图像识别配置参数详细信息
     */
    @PreAuthorize("@ss.hasPermi('tc:config:query')")
    @GetMapping(value = "/{tencentid}")
    public AjaxResult getInfo(@PathVariable("tencentid") Long tencentid) {
        return AjaxResult.success(tcConfigService.selectTcConfigById(tencentid));
    }

    /**
     * 新增腾讯云-图像识别配置参数
     */
    @PreAuthorize("@ss.hasPermi('tc:config:add')")
    @Log(title = "腾讯云-图像识别配置参数", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TcConfig tcConfig) {
        return toAjax(tcConfigService.insertTcConfig(tcConfig));
    }

    /**
     * 修改腾讯云-图像识别配置参数
     */
    @PreAuthorize("@ss.hasPermi('tc:config:edit')")
    @Log(title = "腾讯云-图像识别配置参数", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TcConfig tcConfig) {
        return toAjax(tcConfigService.updateTcConfig(tcConfig));
    }

    /**
     * 删除腾讯云-图像识别配置参数
     */
    @PreAuthorize("@ss.hasPermi('tc:config:remove')")
    @Log(title = "腾讯云-图像识别配置参数", businessType = BusinessType.DELETE)
    @DeleteMapping("/{tencentids}")
    public AjaxResult remove(@PathVariable Long[] tencentids) {
        return toAjax(tcConfigService.deleteTcConfigByIds(tencentids));
    }
}
